/*************************************************************************
 * Name         : sgx545usedefs.h
 * Title        : SGX hw definitions
 *
 * Copyright    : 2005-2006 by Imagination Technologies Limited. All rights reserved.
 *              : No part of this software, either material or conceptual 
 *              : may be copied or distributed, transmitted, transcribed,
 *              : stored in a retrieval system or translated into any 
 *              : human or computer language in any form by any means,
 *              : electronic, mechanical, manual or other-wise, or 
 *              : disclosed to third parties without the express written
 *              : permission of Imagination Technologies Limited, Unit 8, HomePark
 *              : Industrial Estate, King's Langley, Hertfordshire,
 *              : WD4 8LZ, U.K.
 *
 * Platform     : ANSI
 *
 * Modifications:-
 * $Log: sgx545usedefs.h $
 **************************************************************************/

#ifndef _SGX545USEDEFS_H_
#define	_SGX545USEDEFS_H_

#define SGX545_PIXELBE2S2_TWOEMITS					(1UL << 11)

/* 545 extensions of the OP field. */
#define SGX545_USE1_OP_FDUAL						(27UL)

/* 545 changes to the OP2 field for MINMAX floating point instruction. */
#define SGX545_USE1_FLOAT_OP2_MAXMIN				(0)
#define SGX545_USE1_FLOAT_OP2_MINMAX				(1)

/* 545 changes to the floating point instruction fields. */
#define SGX545_USE1_FLOAT_MOE						(0x00200000)

#define SGX545_USE1_FLOAT_RCNT_SHIFT				(12)
#define SGX545_USE1_FLOAT_RCNT_CLRMSK				(0xFFFFCFFF)

#define SGX545_USE1_FLOAT_SRC0ABS					(0x00000080)

#define SGX545_USE1_FLOAT_S0INC						(0x00008000)
#define SGX545_USE1_FLOAT_S1INC						(0x00004000)
#define SGX545_USE1_FLOAT_S2INC						(0x00000100)

#define SGX545_USE1_FLOAT_RCOUNT_MAXIMUM			4

/* 545 changes to the FMAD16 instruction. */
#define SGX545_USE_FARITH16_SWZ_LOWHIGH				0
#define SGX545_USE_FARITH16_SWZ_LOWLOW				1
#define SGX545_USE_FARITH16_SWZ_HIGHHIGH			2
#define SGX545_USE_FARITH16_SWZ_CVTFROMF32			3

#define SGX545_USE1_FARITH16_SRC2SWZ_SHIFT			(21)
#define SGX545_USE1_FARITH16_SRC2SWZ_CLRMSK			(0xFF9FFFFF)

#define SGX545_USE1_FARITH16_SRC1SWZH_SHIFT			(18)
#define SGX545_USE1_FARITH16_SRC1SWZH_CLRMSK		(0xFFFBFFFF)
#define SGX545_USE1_FARITH16_SRC1SWZH_INTERNALSHIFT	(1)

#define SGX545_USE1_FARITH16_SRC1SWZL_SHIFT			(13)
#define SGX545_USE1_FARITH16_SRC1SWZL_CLRMSK		(0xFFFFDFFF)
#define SGX545_USE1_FARITH16_SRC1SWZL_INTERNALSHIFT	(0)

#define SGX545_USE1_FARITH16_RCNT_SHIFT				(12)
#define SGX545_USE1_FARITH16_RCNT_CLRMSK			(0xFFFFEFFF)
#define SGX545_USE1_FARITH16_RCNT_MAXIMUM			(2)

#define SGX545_USE1_FARITH16_SRC0SWZ_SHIFT			(9)
#define SGX545_USE1_FARITH16_SRC0SWZ_CLRMSK			(0xFFFFF9FF)

/* 545 extensions of the scalar instruction fields. */
#define SGX545_USE1_FSCALAR_GROUP					(0x00010000)

#define SGX545_USE1_FLOAT_OP2_SQRT					(0)
#define SGX545_USE1_FLOAT_OP2_SIN					(1)
#define SGX545_USE1_FLOAT_OP2_COS					(2)
#define SGX545_USE1_FLOAT_OP2_SCALARRESERVED		(3)

/* 545 extensions of the MOVC instruction fields. */
#define SGX545_USE1_MOVC_COVERAGETYPEEXT			(0x00400000)

#define SGX545_USE1_MOVC_TSTDTYPE_COVERAGE			(6)
#define SGX545_USE1_MOVC_TSTDTYPE_COVERAGE_SMASK	(7)

#define SGX545_USE1_MOVC_COVERAGETYPE_STDMASK		(0)
#define SGX545_USE1_MOVC_COVERAGETYPE_STDU8			(1)
#define SGX545_USE1_MOVC_COVERAGETYPE_EXTF16		(0)
#define SGX545_USE1_MOVC_COVERAGETYPE_EXTF32		(1)

#define SGX545_USE1_MOVC_S2SCSEL_SHIFT				(5)
#define SGX545_USE1_MOVC_S2SCSEL_CLRMSK				(0xFFFFFF9F)

/* 545 changes to the EFO instruction fields. */
/* Negate right-hand source for A0 addr. */
#define SGX545_USE1_EFO_A0RNEG						(0x04000000)

#define SGX545_USE1_EFO_SPRED_SHIFT					(24)
#define SGX545_USE1_EFO_SPRED_CLRMSK				(0xFCFFFFFF)

/* 545 multiplier selections. */
#define SGX545_USE1_EFO_ASRC_M0M1_I1I0				(0)
#define SGX545_USE1_EFO_ASRC_M0SRC0_I1I0			(1)
#define SGX545_USE1_EFO_ASRC_M0I0_I1M1				(2)
#define SGX545_USE1_EFO_ASRC_SRC0SRC2_SRC1SRC2		(3)

/* 545 adder selections. */
#define SGX545_USE1_EFO_MSRC_SRC0SRC2_SRC1SRC2		(0)
#define SGX545_USE1_EFO_MSRC_SRC2SRC1_SRC2SRC2		(1)
#define SGX545_USE1_EFO_MSRC_SRC1SRC0_SRC2SRC2		(2)
#define SGX545_USE1_EFO_MSRC_SRC1I0_SRC2I1			(3)

#define SGX545_USE1_EFO_GPIROW						(0x00000100)

#define SGX545_USE1_EFO_S2BEXT						(0x00000080)

#define SGX545_USE1_EFO_S0BEXT						(0x00000040)

#define SGX545_USE1_EFO_SRC0NEG						(0x00000020)

#define SGX545_USE1_EFO_SRC1NEG						(0x00000010)

#define SGX545_USE1_EFO_SRC2NEG						(0x00000008)

/*
	Dual-issue instruction fields.
*/
#define SGX545_USE1_FDUAL_SPRED_SHIFT				(24)
#define SGX545_USE1_FDUAL_SPRED_CLRMSK				(0xFCFFFFFF)

#define SGX545_USE1_FDUAL_OP1EXT					(0x04000000)

#define SGX545_USE1_FDUAL_O2S2EXT_MSRCEXT			(0x00200000)

#define SGX545_USE1_FDUAL_OP1_SHIFT					(18)
#define SGX545_USE1_FDUAL_OP1_CLRMSK				(0xFFF3FFFF)
#define SGX545_USE1_FDUAL_OP1_STD_FMAD				(0)
#define SGX545_USE1_FDUAL_OP1_STD_MOV				(1)
#define SGX545_USE1_FDUAL_OP1_STD_FADM				(2)
#define SGX545_USE1_FDUAL_OP1_STD_FMSA				(3)
#define SGX545_USE1_FDUAL_OP1_EXT_FDDP				(0)
#define SGX545_USE1_FDUAL_OP1_EXT_FCLMP				(1)
#define SGX545_USE1_FDUAL_OP1_EXT_IMA32				(2)
#define SGX545_USE1_FDUAL_OP1_EXT_FSSQ				(3)

#define SGX545_USE1_FDUAL_OP2S1_SHIFT				(14)
#define SGX545_USE1_FDUAL_OP2S1_CLRMSK				(0xFFFF3FFF)
#define SGX545_USE1_FDUAL_OP2S1_I0					(0)
#define SGX545_USE1_FDUAL_OP2S1_I1					(1)
#define SGX545_USE1_FDUAL_OP2S1_I2					(2)
#define SGX545_USE1_FDUAL_OP2S1_SRC1				(3)
#define SGX545_USE1_FDUAL_OP2S1_MSRCSTD_I0			(0)
#define SGX545_USE1_FDUAL_OP2S1_MSRCSTD_I1			(1)
#define SGX545_USE1_FDUAL_OP2S1_MSRCSTD_I2			(2)
#define SGX545_USE1_FDUAL_OP2S1_MSRCSTD_RESERVED	(3)
#define SGX545_USE1_FDUAL_OP2S1_MSRCEXT_SRC0		(0)
#define SGX545_USE1_FDUAL_OP2S1_MSRCEXT_SRC1		(1)
#define SGX545_USE1_FDUAL_OP2S1_MSRCEXT_SRC2		(2)
#define SGX545_USE1_FDUAL_OP2S1_MSRCEXT_RESERVED	(3)

#define SGX545_USE1_FDUAL_OP2DEXTS0EXT				(0x00002000)

#define SGX545_USE1_FDUAL_RCNT_SHIFT				(12)
#define SGX545_USE1_FDUAL_RCNT_CLRMSK				(0xFFFFEFFF)
#define SGX545_USE1_FDUAL_RCNT_MAX					(2)

#define SGX545_USE1_FDUAL_NOSCHED					(0x00000800)

#define SGX545_USE1_FDUAL_OP2S2_SHIFT				(10)
#define SGX545_USE1_FDUAL_OP2S2_CLRMSK				(0xFFFFFBFF)
#define SGX545_USE1_FDUAL_OP2S2_STD_I0				(0)
#define SGX545_USE1_FDUAL_OP2S2_STD_I1				(1)
#define SGX545_USE1_FDUAL_OP2S2_EXT_I2				(0)
#define SGX545_USE1_FDUAL_OP2S2_EXT_SRC2			(1)

#define SGX545_USE1_FDUAL_OP2_SHIFT					(6)
#define SGX545_USE1_FDUAL_OP2_CLRMSK				(0xFFFFFC3F)
#define SGX545_USE1_FDUAL_OP2_FMAD					(0)
#define SGX545_USE1_FDUAL_OP2_FMAD16				(1)
#define SGX545_USE1_FDUAL_OP2_FMSA					(2)
#define SGX545_USE1_FDUAL_OP2_FFRC					(3)
#define SGX545_USE1_FDUAL_OP2_FCLMP					(4)
#define SGX545_USE1_FDUAL_OP2_FRCP					(5)
#define SGX545_USE1_FDUAL_OP2_FRSQ					(6)
#define SGX545_USE1_FDUAL_OP2_FEXP					(7)
#define SGX545_USE1_FDUAL_OP2_FLOG					(8)
#define SGX545_USE1_FDUAL_OP2_FSIN					(9)
#define SGX545_USE1_FDUAL_OP2_FCOS					(10)
#define SGX545_USE1_FDUAL_OP2_FADD					(11)
#define SGX545_USE1_FDUAL_OP2_FSUB					(12)
#define SGX545_USE1_FDUAL_OP2_FMUL					(13)
#define SGX545_USE1_FDUAL_OP2_IMA32					(14)
#define SGX545_USE1_FDUAL_OP2_MOV					(15)

#define SGX545_USE1_FDUAL_OP2DSTS0_SHIFT			(5)
#define SGX545_USE1_FDUAL_OP2DSTS0_CLRMSK			(0xFFFFFFDF)
#define SGX545_USE1_FDUAL_OP2DSTS0_STD_I0			(0)
#define SGX545_USE1_FDUAL_OP2DSTS0_STD_I1			(1)
#define SGX545_USE1_FDUAL_OP2DSTS0_EXT_I2			(0)
#define SGX545_USE1_FDUAL_OP2DSTS0_EXT_I0SRC0		(1)
#define SGX545_USE1_FDUAL_OP2DSTS0_MAXIMUM_INTERNAL_REGISTER	\
													(2)

#define SGX545_USE1_FDUAL_S1NEG						(0x00000010)
#define SGX545_USE1_FDUAL_S2NEG						(0x00000008)

/*
	Number of the internal register written by
	a primary FDDP operation (in addition to
	the normal destination).
*/
#define SGX545_USE_FDUAL_FDDP_IREG_DEST_NUM			(0)

/* 545 pack instruction changes. */
#define SGX545_USE0_PCK_RMODE_SHIFT					(19)
#define SGX545_USE0_PCK_RMODE_CLRMSK				(0xFFE7FFFF)
#define SGX545_USE0_PCK_RMODE_NEAREST				(0)
#define SGX545_USE0_PCK_RMODE_DOWN					(1)
#define SGX545_USE0_PCK_RMODE_UP					(2)
#define SGX545_USE0_PCK_RMODE_ZERO					(3)

#define SGX545_USE0_PCK_ROUNDENABLE					(0x00040000)

/*
	IDIV
*/
#define SGX545_USE1_32BITINT_OP2_IDIV				(1)

#define SGX545_USE1_IDIV_DBANK_TEMP					(0x00000000)
#define SGX545_USE1_IDIV_DBANK_PRIMATTR				(0x00000080)
#define SGX545_USE1_IDIV_DBANK_CLRMSK				(0xFFFFFF7F)

#define SGX545_USE1_IDIV_DRCSEL_SHIFT				(0)
#define SGX545_USE1_IDIV_DRCSEL_CLRMSK				(0xFFFFFFFE)
#define SGX545_USE1_IDIV_DRCSEL_MAX					(1)

/*
	545 changes to the SMP instruction.
*/
#define SGX545_USE1_SMP_SRD_SHIFT					(14)
#define SGX545_USE1_SMP_SRD_CLRMSK					(0xFFFF3FFF)
#define SGX545_USE1_SMP_SRD_NONE					(0)
#define SGX545_USE1_SMP_SRD_COEFFS					(1)
#define SGX545_USE1_SMP_SRD_RAWDATA					(2)
#define SGX545_USE1_SMP_SRD_RESERVED				(3)

#define SGX545_USE1_SMP_PCF_SHIFT					(5)
#define SGX545_USE1_SMP_PCF_CLRMSK					(0xFFFFFF9F)
#define SGX545_USE1_SMP_PCF_NONE					(0)
#define SGX545_USE1_SMP_PCF_F32						(1)
#define SGX545_USE1_SMP_PCF_F16						(2)
#define SGX545_USE1_SMP_PCF_RESERVED				(3)

/*
	Number of registers written by a texture sample using SRD=COEFFS
*/
#define SGX545_USE_SMP_SRD_COEFFS_RESULT_LENGTH				(2)

/*
	Format of the data returned by a texture sample using SRD=COEFFS

	Bit		Register offset	Description
	31..24	0				Bilinear S fraction (in case of 3D textures)
	23..16	0				Trilinear fraction
	15..8	0				Bilinear V fraction
	7..0	0				Bilinear U fraction
		
	31..8	1				Reserved
	7..0	1				LOD value
*/
#define SGX545_USE_SMP_SRD_COEFFS0_UFRACTION_SHIFT			(0)
#define SGX545_USE_SMP_SRD_COEFFS0_UFRACTION_CLRMSK			(0xFFFFFF00)

#define SGX545_USE_SMP_SRD_COEFFS0_VFRACTION_SHIFT			(8)
#define SGX545_USE_SMP_SRD_COEFFS0_VFRACTION_CLRMSK			(0xFFFF00FF)

#define SGX545_USE_SMP_SRD_COEFFS0_TRILINEARFRACTION_SHIFT	(16)
#define SGX545_USE_SMP_SRD_COEFFS0_TRILINEARFRACTION_CLRMSK	(0xFF00FFFF)

#define SGX545_USE_SMP_SRD_COEFFS0_SFRACTION_SHIFT			(24)
#define SGX545_USE_SMP_SRD_COEFFS0_SFRACTION_CLRMSK			(0x00FFFFFF)

#define SGX545_USE_SMP_SRD_COEFFS1_LOD_SHIFT				(0)
#define SGX545_USE_SMP_SRD_COEFFS1_LOD_CLRMSK				(0xFFFFFF00)

/*
	545 changes to the LD/ST instruction.
*/
#define SGX545_USE1_LDST_EXTENDED					(0x00400000)

/* Same bit position as DRCSEL for LD */
#define SGX545_USE1_ST_NORDBEF						(0x00000001)

/*
	Extended load instruction fields.
*/
#define SGX545_USE1_EXTLD_DCCTLEXT					(0x00200000)

#define SGX545_USE1_EXTLD_OFFSET1_CLRMSK			(0xFFF0FFFF)
#define SGX545_USE1_EXTLD_OFFSET1_SHIFT				(16)
#define SGX545_USE1_EXTLD_OFFSET1_INTERNALSHIFT		(7)

#define SGX545_USE1_EXTLD_OFFSET0_CLRMSK			(0xFFFFF01F)
#define SGX545_USE1_EXTLD_OFFSET0_SHIFT				(5)
#define SGX545_USE1_EXTLD_OFFSET0_INTERNALSHIFT		(0)

#define SGX545_USE1_EXTLD_OFFSET_MAX				(2047)

#define SGX545_USE1_EXTLD_DBANK_TEMP				(0x00000000)
#define SGX545_USE1_EXTLD_DBANK_PRIMATTR			(0x00000010)
#define SGX545_USE1_EXTLD_DBANK_CLRMSK				(0xFFFFFFEF)

#define SGX545_USE1_EXTLD_DTYPE_32BIT				(0x00000000)
#define SGX545_USE1_EXTLD_DTYPE_128BIT				(0x00000008)

/*
	The maximum value for the range check parameter for each data type
	(in units of that data type).
*/
#define SGX545_USE_EXTLD_MAXIMUM_DWORD_RANGE		(0x1FFFFFFF)
#define SGX545_USE_EXTLD_MAXIMUM_QWORD_RANGE		(0x07FFFFFF)

/*
	USE to MTE emit for 545
*/

#define SGX545_USETOMTE2_OVERRIDESYNCNUM			(0x00000001)

#define SGX545_USETOMTE1_COMPLEX					(0x00100000)

#define SGX545_USETOMTE1_VERTEXC_RESOURCENUM_SHIFT	(7)
#define SGX545_USETOMTE1_VERTEXC_RESOURCENUM_CLRMSK	(0xFFFFFC7F)

#define SGX545_USETOMTE1_VERTEXC_VERINPART_SHIFT	(3)
#define SGX545_USETOMTE1_VERTEXC_VERINPART_CLRMSK	(0xFFFFFF87)

#define SGX545_USETOMTE1_VERTEXS_RESOURCENUM_SHIFT	(3)
#define SGX545_USETOMTE1_VERTEXS_RESOURCENUM_CLRMSK	(0xFFFFFFC7)

#define SGX545_USETOMTE1_PRIM_TYPE_SHIFT			(13)
#define SGX545_USETOMTE1_PRIM_TYPE_CLRMSK			(0xFFFFDFFF)
#define SGX545_USETOMTE1_PRIM_TYPE_TRIANGLE			(0)
#define SGX545_USETOMTE1_PRIM_TYPE_STRIP			(1)

#define SGX545_USETOMTE1_PRIM_START_SHIFT			(8)
#define SGX545_USETOMTE1_PRIM_START_CLRMSK			(0xFFFFE0FF)

#define SGX545_USETOMTE1_PRIM_NUM_SHIFT				(3)
#define SGX545_USETOMTE1_PRIM_NUM_CLRMSK			(0xFFFFFF07)

#define SGX545_USETOMTE1_NUMPARTITIONS_SHIFT		(0)
#define SGX545_USETOMTE1_NUMPARITIIONS_CLRMSK		(0xFFFFFFF8)

/* New special opcodes for 545. */
#define SGX545_USE1_OTHER2_OP2_CFI					(0)
#define SGX545_USE1_OTHER2_OP2_RESERVED				(1)

/* MOE instructions. */
#define SGX545_USE1_MOECTRL_OP2_MOEST				(6)

#define SGX545_USE1_MOECTRL_MOEST_PARAM_CLRMSK		(0xFFFF87FF)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SHIFT		(11)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMOALOW		(0)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMOAHIGH	(1)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMLSILOW	(2)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMLSIHIGH	(3)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMBOLOW		(4)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMBOHIGH	(5)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMRLOW		(6)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_SMRHIGH		(7)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_IDX			(8)
#define SGX545_USE1_MOECTRL_MOEST_PARAM_MAXIMUM		(8)

/* Cache flush instruction. */
#define SGX545_USE1_OTHER2_CFI_GLOBAL				(0x00008000)
#define SGX545_USE1_OTHER2_CFI_DM_NOMATCH			(0x00004000)
#define SGX545_USE1_OTHER2_CFI_FLUSH				(0x00002000)
#define SGX545_USE1_OTHER2_CFI_INVALIDATE			(0x00001000)

#define SGX545_USE1_OTHER2_CFI_LEVEL_CLRMSK			(0xFFFFFCFF)
#define SGX545_USE1_OTHER2_CFI_LEVEL_SHIFT			(8)
#define SGX545_USE1_OTHER2_CFI_LEVEL_RESERVED		(0)
#define SGX545_USE1_OTHER2_CFI_LEVEL_L0L1			(1)
#define SGX545_USE1_OTHER2_CFI_LEVEL_L2				(2)
#define SGX545_USE1_OTHER2_CFI_LEVEL_L0L1L2			(3)
#define SGX545_USE1_OTHER2_CFI_LEVEL_MAX			(3)

#define SGX545_USE_OTHER2_CFI_DATAMASTER_VERTEX		(0)
#define SGX545_USE_OTHER2_CFI_DATAMASTER_PIXEL		(1)
#define SGX545_USE_OTHER2_CFI_DATAMASTER_RESERVED	(2)
#define SGX545_USE_OTHER2_CFI_DATAMASTER_EVENT		(3)

/* WOP instruction. */
#define SGX545_USE0_WOP_TWOPART						(0x00000008)
#define SGX545_USE0_WOP_PTNB_SHIFT					(0)
#define SGX545_USE0_WOP_PTNB_CLRMSK					(0xFFFFFFF8)
#define SGX545_USE0_WOP_PTNB_MAX					(5)

/* Emit instruction. */
#define SGX545_USE1_EMIT_TARGET_VCB					(3)

#define SGX545_USE1_EMIT_MTE_CUT					(0x00002000)

#define SGX545_USE1_EMIT_INCP_MAX					(5)

#define SGX545_USE1_EMIT_VCB_EMITTYPE_SHIFT			(12)
#define SGX545_USE1_EMIT_VCB_EMITTYPE_CLRMSK		(0xFFFFEFFF)
#define SGX545_USE1_EMIT_VCB_EMITTYPE_STATE			(0)
#define SGX545_USE1_EMIT_VCB_EMITTYPE_VERTEX		(1)

#define SGX545_USE1_EMIT_VERTEX_TWOPART				(0x00000400)
#define SGX545_USE1_EMIT_STATE_THREEPART			(0x00000400)

#define SGX545_USE1_EMIT_INCPEXT_SHIFT				(9)
#define SGX545_USE1_EMIT_INCPEXT_CLRMSK				(0xFFFFFDFF)
#define SGX545_USE1_EMIT_INCPEXT_INTERNALSHIFT		2

#endif	/* _SGX545USEDEFS_H_ */

/* EOF */

